﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TETRIS_v01.FieldObjects;
using System.Threading;


namespace TETRIS_v01.GameHost
{
    public class ShapeGenerator
    {
        public Shape[] ShapeStack { get; protected set; }
        private Random rnd = new Random();

        public ShapeGenerator()
        {
            ShapeStack = new Shape[3];            
            ShapeStack[0] = GenerateRandomShape();
            ShapeStack[1] = GenerateRandomShape();
            ShapeStack[2] = GenerateRandomShape();
        }

        public void AddNewShape()
        {
            ShapeStack[0] = ShapeStack[1];
            ShapeStack[1] = ShapeStack[2];
            ShapeStack[2] = GenerateRandomShape();
        }

        public Shape GenerateRandomShape()
        {
            Shape Sh = null;
            int shapeVar = rnd.Next(1, 8);
            switch (shapeVar)
            {
                case 1: Sh = new Stick(ConsoleColor.DarkGreen); break;
                case 2: Sh = new Square(ConsoleColor.Red); break;
                case 3: Sh = new Shape_Z(ConsoleColor.DarkBlue); break;
                case 4: Sh = new Shape_Z_reverse(ConsoleColor.DarkRed); break;
                case 5: Sh = new Shape_L(ConsoleColor.DarkCyan); break;
                case 6: Sh = new Shape_L_reverse(ConsoleColor.DarkMagenta); break;
                case 7: Sh = new Shape_T(ConsoleColor.Blue); break;
            }
            return Sh;
        }

        

    }
}
